//
// Created by hjie on 23-10-6.
//

#pragma once
extern "C"
{
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libavutil/avutil.h>
#include <libavutil/timestamp.h>
#include <libavutil/threadmessage.h>
#include <libavcodec/packet.h>
#include <libavfilter/avfilter.h>
#include <libavutil/mem.h>
#include <libavutil/opt.h>
#include <libavfilter/buffersrc.h>
#include <libavfilter/buffersink.h>

};

#include <cstring>
#include <string>
#include "codec_config.h"
#include "filter_util.h"

struct DateDrawTextConfig
{
	int m_font_size{15};
	std::string m_font_color{"black"};
	int m_x_position{0};
	int m_y_position{0};
	int m_box{0};
	std::string m_box_color{"white"};
	// pix fmts
};

// ffmpeg command vf option "drawtext=fontsize=60:fontfile=FreeSerif.ttf:text='%{localtime:%Y-%m-%d %H-%M-%S}':fontcolor=green:box=1:boxcolor=yellow"
class DateFilter 
{
public:
	void CodeConfig(CodecConfig & codec_config);
	bool InitDateFilter(int font_size, const std::string & font_color, int x_pos, int y_pos, int box, const std::string box_color);
	bool InitDateFilter(DateDrawTextConfig & config);
	DateFilter();
	~DateFilter();
public:
	AVFilterContext * m_input_filter_ctx;
	AVFilterContext * m_output_filter_ctx;
	AVFilterGraph   * m_filter_graph;	
	int               m_is_init_success;
private:
	bool m_is_set_config;
	CodecConfig m_input_parameter;
private:
	FilterScopeGuard m_scope_guard;
};



